package cn.edu.swufe.surverpark.struts2.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.edu.swufe.surverpark.model.Right;
import cn.edu.swufe.surverpark.struts2.service.RightService;

/**
 *@author 陈龙 E-mail:529914446@qq.com
 *@version创建时间:2015年5月6日上午2:17:07
 *类说明
 */
@Controller
@Scope("prototype")
public class RightAction extends BaseAction<Right> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7660798283217862275L;
	
	@Resource
	private RightService rightService;
	
	private List<Right> allRights;
	
	
	public String findAllRights(){
		this.allRights = rightService.findAllEntities();
		return "rightListPage";
	}


	public List<Right> getAllRights() {
		return allRights;
	}


	public void setAllRights(List<Right> allRights) {
		this.allRights = allRights;
	}

	public String toAddRightPage(){
		
		return "AddRightPage";
	}
	
	public String saveOrUpdateRight(){
	
		rightService.saveOrUpdateRight(model);
		return "findAllRightAction";
	}
	
	private Integer rightId;
	
	public String editRight(){
		this.model = rightService.getEntity(rightId);
		return "AddRightPage";
	}


	public Integer getRightId() {
		return rightId;
	}


	public void setRightId(Integer rightId) {
		this.rightId = rightId;
	}
	
	public String deleteRight(){
		Right r = new Right();
		r.setId(rightId);
		rightService.deleteEntity(r);
		return "findAllRightAction";
	}
	
	public String batchUpdateRights(){
		rightService.batchUpdateRights(allRights);
		return "findAllRightAction";
	}

}

